package com.webshooter.entity;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.Startup;
import javax.inject.Singleton;

@Singleton
@Startup
public class EntityContainer {

    private List<Entity> entities;

    @PostConstruct
    void init() {
        entities = new ArrayList<>();
    }

    public void add(Entity entity) {
        entities.add(entity);
    }

    public List<Entity> getAllEntities() {
        return entities;
    }

    public Entity findEntityByName(String name) {
        for (Entity entity : entities) {
            if (entity.name.equals(name)) {
                return entity;
            }
        }
        return null;
    }
}
